<html>
<head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head>
<body>
<?
set_time_limit(1200);
error_reporting(0);
mysql_connect("dev.ivaldi.nl", "root", "w8woord-ivaldi") or die(mysql_error());
mysql_select_db("publicationsv2") or die(mysql_error());
$query = mysql_query("SELECT DISTINCT name FROM authors_dn");

$i = 0;
while($res = mysql_fetch_array($query)){

	if($i==10){
		//break;
	}

	$userAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
	$target_url = "http://dblp.uni-trier.de/search/author?xauthor=".urlencode($res['name']);

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
	curl_setopt($ch, CURLOPT_URL,$target_url);
	curl_setopt($ch, CURLOPT_FAILONERROR, true);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
	curl_setopt($ch, CURLOPT_AUTOREFERER, true);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
	curl_setopt($ch, CURLOPT_TIMEOUT, 30);
	$html = curl_exec($ch);
	$dom = new DOMDocument();
	@$dom->loadHTML($html);

	$authors = $dom->getElementsByTagName("author");

	foreach( $authors as $author ){
		$name = $authors->item(0)->nodeValue;			
		echo $res['name']. ' -&nbsp;&nbsp;&nbsp;&nbsp; http://dblp.l3s.de/d2r/page/authors/'.str_replace("+","_",urlencode($name))."<br/>";
		
		$sql = "INSERT INTO authors_sameas (id, subject, object) VALUES ('', '".$res['name']."', 'http://dblp.l3s.de/d2r/page/authors/".str_replace("+","_",urlencode($name))."')";
		mysql_query($sql);
		$i++;
		break;
	}
}

?>